var qqmapsdk, QQMapWX = require("../../resource/js/qqmap-wx-jssdk.min.js"), config = require("../../resource/js/config.js"), markersData = [], app = getApp();

Page({
    data: {
        autoplay: !0,
        interval: 3e3,
        duration: 1e3,
        circular: !0,
        indicatorDots: !1,
        indicatorcolor: "#000",
        vertical: !1,
        imgheights: [],
        imgwidth: 750,
        current: 0
    },
    imageLoad: function(a) {
        var t = a.detail.width, e = t / (i = a.detail.height);
        console.log("ffffffffffff"), console.log(t, i);
        var i = 750 / e, n = this.data.imgheights;
        n.push(i), this.setData({
            imgheights: n
        });
    },
    bindchange: function(a) {
        console.log(a.detail.current), this.setData({
            current: a.detail.current
        });
    },
    onShow: function(a) {
        var i = this;
        i.setData({
            isshow: !0
        }), app.util.request({
            url: "entry/wxapp/Sysinit",
            data: {},
            success: function(a) {
                if (!a.data.message.errno) if (0 == a.data.data.intro.ischeck) {
                    var t = wx.getStorageSync("cityinfo");
                    t ? (wx.setStorageSync("city", t.name), i.initpage()) : (qqmapsdk = new QQMapWX({
                        key: "5D3BZ-J55WF-SFPJJ-NI6PG-YN2ZO-M4BHX"
                    }), wx.getLocation({
                        type: "gcj02",
                        success: function(a) {
                            qqmapsdk.reverseGeocoder({
                                location: {
                                    latitude: a.latitude,
                                    longitude: a.longitude
                                },
                                success: function(a) {
                                    var t = a.result.address_component.city, e = t.substr(0, t.length - 1);
                                    wx.setStorageSync("city", e), i.initpage();
                                }
                            });
                        },
                        fail: function() {
                            i.initpage();
                        },
                        complete: function() {}
                    }));
                } else wx.redirectTo({
                    url: "/weixinmao_zp/pages/article/index"
                });
            }
        });
    },
    initpage: function() {
        var t = this, a = wx.getStorageSync("city");
        app.util.request({
            url: "entry/wxapp/GetIndexList",
            data: {
                city: a
            },
            success: function(a) {
                a.data.message.errno || (0 == a.data.data.intro.ischeck ? (wx.setStorageSync("companyinfo", a.data.data.intro), 
                wx.setStorageSync("companyinfo", a.data.data.intro), console.log(a.data.data.cityinfo), 
                wx.setStorageSync("cityinfo", a.data.data.cityinfo), wx.setNavigationBarTitle({
                    title: wx.getStorageSync("companyinfo").name
                }), t.setData({
                    companylist: a.data.data.companylist,
                    notelist: a.data.data.notelist,
                    joblist: a.data.data.joblist,
                    intro: a.data.data.intro,
                    banners: a.data.data.bannerlist,
                    navlist: a.data.data.navlist,
                    isshow: !1,
                    city: wx.getStorageSync("cityinfo").name
                })) : wx.redirectTo({
                    url: "/weixinmao_zp/pages/article/index"
                }));
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    toNagivate: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: t
        });
    },
    toSwitchtab: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.switchTab({
            url: t
        });
    },
    toWxapp: function(a) {
        var t = a.currentTarget.dataset.id, e = a.currentTarget.dataset.appid;
        console.log(t), console.log(e), wx.navigateToMiniProgram({
            appId: e,
            path: t,
            extraData: {
                foo: "bar"
            },
            envVersion: "develop",
            success: function(a) {}
        });
    },
    toAgentlist: function() {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/agentlist/index"
        });
    },
    toMyNote: function(a) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/mynote/index"
        });
    },
    toRegmoney: function() {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/regmoney/index"
        });
    },
    toRegsub: function() {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/regsub/index"
        });
    },
    toMySave: function(a) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/mysave/index"
        });
    },
    toNearjob: function(a) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/nearjob/index"
        });
    },
    toFindjob: function(a) {
        wx.switchTab({
            url: "/weixinmao_zp/pages/findjob/index"
        });
    },
    toFindpartjob: function(a) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/findpartjob/index"
        });
    },
    toFindworker: function(a) {
        wx.switchTab({
            url: "/weixinmao_zp/pages/findworker/index"
        });
    },
    toNotice: function(a) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/mynotice/index"
        });
    },
    toJobDetail: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/weixinmao_zp/pages/jobdetail/index?id=" + t
        });
    },
    toWorkerdetial: function(a) {
        var t = a.currentTarget.id;
        wx.navigateTo({
            url: "/weixinmao_zp/pages/workerdetail/index?id=" + t
        });
    },
    toCompanydetial: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/weixinmao_zp/pages/companydetail/index?id=" + t
        });
    },
    toArticle: function(a) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/article/index"
        });
    },
    toLogin: function(a) {
        0 < wx.getStorageSync("companyid") ? wx.navigateTo({
            url: "/weixinmao_zp/pages/companylogin/index"
        }) : wx.navigateTo({
            url: "/weixinmao_zp/pages/message/index"
        });
    },
    toActive: function(a) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/active/index"
        });
    },
    toAddCompanyjob: function(a) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/addCompanyjob/index"
        });
    },
    toNewHouseDetail: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/weixinmao_zp/pages/newhousedetail/index?id=" + t
        });
    },
    toOldHouseDetail: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/weixinmao_zp/pages/oldhousedetail/index?id=" + t
        });
    },
    toLethouse: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/weixinmao_zp/pages/lethouselist/index?id=" + t
        });
    },
    toMessage: function(a) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/message/index"
        });
    },
    toSearch: function(a) {
        wx.navigateTo({
            url: "/weixinmao_zp/pages/search/index"
        });
    },
    goMap: function(a) {
        wx.openLocation({
            latitude: parseFloat(wx.getStorageSync("companyinfo").lat),
            longitude: parseFloat(wx.getStorageSync("companyinfo").lng),
            scale: 18,
            name: wx.getStorageSync("companyinfo").name,
            address: wx.getStorageSync("companyinfo").address
        });
    },
    onReady: function() {},
    bindInput: function(a) {
        this.setData({
            inputValue: a.detail.value
        }), this.onShow();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        wx.showNavigationBarLoading(), this.onLoad();
    },
    doCall: function() {
        var a = this.data.textData.shop_tel;
        wx.makePhoneCall({
            phoneNumber: a
        });
    },
    onShareAppMessage: function() {
        return {
            title: wx.getStorageSync("companyinfo").name,
            path: "/weixinmao_zp/pages/index/index"
        };
    }
});